﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Rotempco.Core.Web.CRUD.Objects;
using Rotempco.Core.Web.Logic;

namespace Rotempco.Website.MasterPages.UserControls
{
    public partial class DefaultMultiColumnPageHeader : System.Web.UI.UserControl
    {
        private PageListMultiColumnContainer DetailPageContainer;

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        public void SetDetailsList(PageListMultiColumnContainer detailPageContainer)
        {
            DetailPageContainer = detailPageContainer;

            string newPageUrl = "Edit.aspx";
            if (!string.IsNullOrWhiteSpace(detailPageContainer.NewButtonPageIfItsNotEdit))
            {
                newPageUrl = detailPageContainer.NewButtonPageIfItsNotEdit;
            }

            if (!detailPageContainer.HideAddNewButton && UrlLogic.AspxFileExist(newPageUrl))
                hyperLink_New.NavigateUrl = UrlLogic.GotoUrl(url: UrlLogic.GetStaticBaseUrl() + "/" + newPageUrl);
            else
                placeholder_New.Visible = false;

            Label_PageTitle.Text = detailPageContainer.PageTitle;

        }
    }
}